<?php

namespace App\Console\Commands\Assess;

use App\Services\Assess\OrderAndCustomersOrderService;
use App\Services\Assess\SendLogService;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class CheckActivateIp extends Command
{
    /**
     * D:\phpstudy_pro\Extensions\php\php7.3.4nts\php.exe   D:\winsdom_seller\artisan check_ip --date=1
     * linux定时同步订单 /usr/local/phpstudy/soft/php/php-7.4.0/bin/php /www/admin/winsdom_seller/artisan check_ip
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'check_ip
                            {--ip=}
                            {--date=}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '定时检查访问日志ip';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {

        $ip = $this->option('ip');
        $date = $this->option('date');
        $params = [];
        $SendLogService = new SendLogService();
        if (!empty($ip)) $params['ip'] = $ip;
        if (!empty($date)) {
            $YesterdayDate = date('Y-m-d', strtotime("-$date day"));
            $nowDate = date('Y-m-d',time());
            $params['start_date'] = $YesterdayDate . ' 00:00:00';
            $params['end_date'] = $nowDate . ' 23:59:59';
        }

        $SendLogService->checkActivateIp($params);

        exit('SUCCESS');
    }
}



